//CREATED BY andysal on 05/09/2005
//UPDATED BY andysal on 10/01/2010
using System;
using System.Collections.Generic;
using System.Drawing;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

namespace Grebok.Domain
{
    /// <summary>
    /// Defines an entity representing an employee
    /// </summary>
    public class Employee : DomainObject
	{
		private Employee manager;
        private IList<Territory> territories = new List<Territory>();

        public static Employee CreateNewEmployee(string firstName, string lastName, DateTime birthDate, DateTime hireDate, string jobTitle)
        {
            if (firstName == null)
            {
                throw new ArgumentNullException("firstName", "First name cannot be null");
            }
            if (lastName == null)
            {
                throw new ArgumentNullException("lastName", "Last name cannot be null");
            }
            if (jobTitle == null)
            {
                throw new ArgumentNullException("jobTitle", "Job title cannot be null");
            }
            Employee e = new Employee();
            e.FirstName = firstName;
            e.LastName = lastName;
            e.BirthDate = birthDate;
            e.HireDate = hireDate;
            e.JobTitle = jobTitle;
            return e;
        }

        /// <summary>
        /// Gets or sets the id of the employee
        /// </summary>
		[NotNullValidator()]
        public virtual int Id { get; set; }

        /// <summary>
        /// Gets or sets the first name
        /// </summary>
		[NotNullValidator()]
        public virtual string FirstName { get; set; }

        /// <summary>
        /// Gets or sets the last name
        /// </summary>
		[NotNullValidator()]
        public virtual string LastName { get; set; }

        /// <summary>
        /// Gets or sets the job title
        /// </summary>
        public virtual string JobTitle { get; set; }

        /// <summary>
        /// Gets or sets the title of courtesy
        /// </summary>
        public virtual string TitleOfCourtesy { get; set; }

        /// <summary>
        /// Gets or sets the birth date
        /// </summary>
        public virtual DateTime BirthDate { get; set; }

        /// <summary>
        /// Gets or sets the Hire Date
        /// </summary>
        public virtual DateTime HireDate { get; set; }

        /// <summary>
        /// Gets or sets the Home Phone
        /// </summary>
        public virtual string HomePhone { get; set; }

        /// <summary>
        /// Gets or sets the Extension
        /// </summary>
        public virtual string Extension { get; set; }

        /// <summary>
        /// Gets or sets the Notes
        /// </summary>
        public virtual string Notes { get; set; }

        /// <summary>
        /// Gets or sets the Photo path
        /// </summary>
        public virtual string PhotoPath { get; set; }
        
        /// <summary>
        /// Gets or sets the Address info
        /// </summary>
        public virtual AddressInfo AddressInfo { get; set; }

        public virtual IList<Territory> Territories { get; set; }

        /// <summary>
        /// Gets or sets the Photo
        /// </summary>
        public virtual Bitmap Photo { get; set; }

        /// <summary>
        /// Gets or sets the Manager
        /// </summary>
        public virtual Employee Manager
		{
			get
			{
                if (manager == null)
                {
                    return new MissingEmployee();
                }
                else
                {
                    return manager;
                }
			}
			set
			{
				manager = value;
			}
		}
	}
}
